/*	$Id: pforge.h 7 2008-07-29 02:58:11Z phrakt $	*/
/*
 * Copyright (c) 2003, 2005 Jean-Francois Brousseau <jfb@openbsd.org>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef _PFORGE_PFORGE_H_
#define _PFORGE_PFORGE_H_

#include <sys/types.h>

#include <stdint.h>


#ifndef PF_PATH_CONF
#define PF_PATH_CONF	"/usr/local/etc/pforge.conf"
#endif

/* environment variables */
#define PF_ENV_CONF	"PFCONF"

#define PF_OK      0
#define PF_ERROR  (-1)


/* error codes */
#define PF_ERR_NOERR      0
#define PF_ERR_INVARG     1
#define PF_ERR_NOENT      2
#define PF_ERR_NOMEM      3
#define PF_ERR_NOFILE     4
#define PF_ERR_TIMEOUT    5
#define PF_ERR_RANGE      6
#define PF_ERR_DEADLOCK   7
#define PF_ERR_NOPERM     8
#define PF_ERR_INVOP      9
#define PF_ERR_NOTSUP    10
#define PF_ERR_VERSION   11
#define PF_ERR_RESRC     12
#define PF_ERR_DATAERR   13
#define PF_ERR_INVPROTO  14
#define PF_ERR_INVPRFAM  15
#define PF_ERR_INVLYR    16
#define PF_ERR_INERR     17
#define PF_ERR_OUTERR    18
#define PF_ERR_SYMRES    19
#define PF_ERR_NOTDIR    20
#define PF_ERR_TRUNC     21
#define PF_ERR_OFLOW     22

#define PF_ERR_MAXERR    22	/* update */



int         pf_init     (void);
void        pf_cleanup  (void);
int         pf_geterr   (void);
void        pf_seterr   (int);
const char* pf_errstr   (int);
int         pf_readconf (const char *);

void*       pf_malloc   (size_t);
void*       pf_realloc  (void *, size_t);
char*       pf_strdup   (const char *);
void        pf_free     (void *);

/* PRNG interface */
int         pf_rand_get    (void *dst, size_t);
uint8_t     pf_rand_get8   (void);
uint16_t    pf_rand_get16  (void);
uint32_t    pf_rand_get32  (void);


#endif	/* _PFORGE_PFORGE_H_ */
